App({
    onLaunch: function() {
        //调用API从本地缓存中获取数据
        //var logs = wx.getStorageSync('logs') || []
        //logs.unshift(Date.now())
        //wx.setStorageSync('logs', logs)
    },
    getUserInfo: function(cb) {
        var that = this
        if (this.globalData.userInfo) {
            typeof cb == "function" && cb(this.globalData.userInfo)
        } else {
            //调用登录接口
            wx.login({
                success: function(r) {
                    that.globalData.userCode = r.code;
                    wx.getUserInfo({
                        success: function(res) {
                            that.globalData.userInfo = res.userInfo;
                            typeof cb == "function" && cb(that.globalData.userInfo);
                        },
                        fail: function(res) {
                            typeof cb == "function" && cb(that.globalData.userInfo);
                        }
                    })
                }
            })
        }
    },

    setUserSid: function(sid) {
        this.globalData.userSid = sid;
    },
    getUserSid: function() {
        return this.globalData.userSid;
    },
    setComId: function(comId) {
        this.globalData.comId = comId;
    },
    getComId: function() {
        return this.globalData.comId;
    },
    setOpenId(openId) {
        this.globalData.openId = openId;
    },
    getOpenId() {
        return this.globalData.openId;
    },
    getShop() {
        return this.globalData.shop;
    },
    setShop(shop) {
        this.globalData.shop = shop;
    },
    getHost() {
        return this.config.apiUrl;
    },
    setHost(host) {
        this.config.apiUrl = host;
    },
    getAlias() {
        return this.globalData.alias;
    },
    setAlias(alias) {
        this.globalData.alias = alias;
    },
    setLocation(lat, lng) {
        this.globalData.location = {
            lng,
            lat,
        };
    },
    getLocation() {
        return this.globalData.location;
    },
    getUserData() {
        return this.globalData.userData;
    },
    setUserData(userData) {
        this.globalData.userData = userData;
    },

    setCanPay(flag) {
        this.globalData.isPay = flag;
    },
    getCanPay() {
        return this.globalData.isPay;
    },
    getIsFenxiao() {
        return this.globalData.is_fenxiao;
    },
    setIsFenxiao(is_fenxiao) {
        this.globalData.is_fenxiao = is_fenxiao;
    },
    getUserId() {
        return this.globalData.user_id;
    },
    setUserId(user_id) {
        this.globalData.user_id = user_id;
    },
    getRecommend() {
        return this.globalData.recommend;
    },
    setRecommend(recommend) {
        this.globalData.recommend = recommend;
    },
    getPrecommend() {
        return this.globalData.Precommend;
    },
    setPrecommend(Precommend) {
        this.globalData.Precommend = Precommend;
    },
    getWinHei() {
        return this.globalData.winHei;
    },
    setWinHei(winHei) {
        this.globalData.winHei = winHei;
    },
    getWinWid() {
        return this.globalData.winWid;
    },
    setWinWid(winWid) {
        this.globalData.winWid = winWid;
    },
    globalData: {
        // alias: 'b9e',
        appType: [],
        openId: null,
        userSid: '',
        userData: null,
        userInfo: null,
        shop: null, //当前店铺信息
        userCode: null,
        comId: null,
        location: {
            lng: '',
            lat: '',
        },
        isPay: false,
        is_fenxiao: null,
        user_id: null,
        recommend: null,
        Precommend: null,
        techId: '', //与该账号绑定的技师id

        winHei: 0,
    },
    config: {
        apiUrl: 'https://api.y.88ff.com',
        // apiUrl: 'https://api.yun.taojinzi.cn'

        modMapping: {
            1: 'mText',
            2: 'mImage',
            3: 'mSwiper',
            4: 'mForm',
            5: 'mVideo',
            6: 'tabBar',
            7: 'search',
            8: 'mImageList',
            9: 'mTitle',
            10: 'mCase',
            11: 'mUeditor',
            12: 'mButton',
            101: 'shopInfoIndex',
            102: 'gModList',
            103: 'waiterList',
            104: 'homeCatList',
            105: 'homeCardList',
            106: 'nearShop',
            107: 'connectKf',
            108: 'artList',
            109: 'goodsList',
            110: 'shopInfoRow',
            111: 'nearShopList',
            112: 'seckillList',
            113: 'groupBuy',
            114: 'cutList',
            115: 'agentSearch',
            116: 'cateList',
        },

        appTypeMap: {
            ysc: 1, //七彩云商城
            wgw:2, //微官网（门店版）
            wd: 3, //微小店版
            wsc: 4, //微商城版
            dc: 5, //点餐版
            meiye: 6, //美业专属版
            wgw01: 7, //微官网传统版
        },
    }
})